<?php

// lookup the most recent instance
$query = "SELECT id, state, days, style, start_node, stale_dn, track_id"
   		." FROM n_adc";
$result = db_query($query);
if(!$result) {
	echo "error: wasn't able to find list in the instance\n";
	exit(1);
}
// loop through until we have the last instance
while($next = mysql_fetch_assoc($result)) {
	$instance = mysql_fetch_assoc($result);
}

// loop through until we have the last instance
while($next = mysql_fetch_assoc($result)) {
	$instance = mysql_fetch_assoc($result);
}

// display current exceptions
$query = "SELECT id, pattern, addedBy, UNIX_TIMESTAMP(dt), days, note, isActive, isElapsed"
// 		." FROM n_adc_exceptions WHERE isActive=0 ORDER BY dt DESC";
   		." FROM n_adc_exceptions WHERE isElapsed=1 ORDER BY dt DESC";
$result = db_query($query);
if(!$result) {
	echo "error: wasn't able to find list in the instance\n";
	exit(1);
}
?>

<script>
tables.push([
	"table_exception_expired",
	google.visualization.arrayToDataTable([
		['Date', 'Pattern', 'AddedBy', 'Days', 'Note']

<?php
while($next = mysql_fetch_assoc($result)) {
	echo ",["
		."'". date("Y-m-d", $next["UNIX_TIMESTAMP(dt)"]) ."'"
		.",'".  $next["pattern"] ."'"
		.",'".  $next["addedBy"] ."'"
		.",'".  $next["days"] ."'"
		.",'".  $next["note"] ."'"
		."]\n";
}
?>
		])
	]);
</script>
